package com.qunar.tech.team12.hotel.parser;

import com.qunar.tech.team12.hotel.bean.Hotel;
import javafx.util.Pair;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by mzy on 14-7-21.
 */
public class Query {

    public static enum ParamType {
        CITY() {
            public void setProperty(String v, Query query) {

            }
        }, NAME() {
            public void setProperty(String v, Query query) {

            }
        }, ADDRESS() {
            public void setProperty(String v, Query query) {

            }
        }, BRAND() {
            public void setProperty(String v, Query query) {

            }
        },;

        public abstract void setProperty(String v, Query query);
    }

    private String city;
    private String name;
    private String address;
    private String brand;
    private String area;
    private String sort;
    private String order;
    private Pair<String, String> starRange;
    private List<Pair<String, String>> priceRange = new ArrayList<Pair<String, String>>();

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public void setStarRange(String start, String end) {

        starRange = new Pair<String, String>(start, end);
    }

    public Pair<String, String> getStarRange() {
        return starRange == null ? new Pair<String, String>("", "") : starRange;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj instanceof Hotel) {
            Hotel hotel = (Hotel) obj;
            if (this.getName().equals(hotel.getName())
                    && this.getAddress().equals(hotel.getAddress())
                    && this.getBrand().contains(hotel.getProperties().get("brand"))
                    && this.getArea().equals(hotel.getProperties().get("area"))
                    && this.getStarRange().getKey().compareTo(hotel.getProperties().get("star")) < 0
                    && this.getStarRange().getValue().compareTo(hotel.getProperties().get("star")) > 0) {
                return true;
            }
        }
        return false;
    }
}
